<?php
    debug($json_data);
?>

<div style="float:right;">
    <table class="tablep table-bordered">
        <thead>
            <tr>
                <th>Date</th>
                <th>Invoice Number</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><?php echo $json_data['Sale']['purchased_date'];?></td>
                <td><?php echo $json_data['Sale']['invoice_number'];?></td>
            </tr>
        </tbody>
    </table>
</div>

<div style="display: block; clear:both;"></div>

<div style="float:left;">
    <table class="tablep table-bordered">
        <thead>
            <tr>
                <th>Bill To</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><?php echo $json_data['Customer']['name'];?></td>
            </tr>
        </tbody>
    </table>
</div>

<div style="display: block; clear:both;"></div>

<!--<div style="float:right;">
    <table class="tablep table-bordered">
        <thead>
            <tr>
                <th>P.O. No.</th>
                <th>Terms</th>
                <th>Project</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
        </tbody>
    </table>
</div>-->

<div>
    <table class="tablep table-bordered">
        <thead>
            <tr>
                <th>Quantity</th>
                <th>Description</th>
                <th>Rate</th>
                <th>Amount</th>
            </tr>
        </thead>
        <tbody>
        <?php
        foreach($json_data['SaleItem'] as $item){
        ?>
            <tr>
                <td><?php echo $item['quantity'];?></td>
                <td><?php echo $item['description'];?></td>
                <td><?php echo $item['rate'];?></td>
                <td><?php echo $item['amount'];?></td>
            </tr>
        <?php
            }
        ?>
        <tr>
            <td colspan="4">&nbsp;</td>
        </tr>
        <?php
            foreach($json_data['Extra'] as $item){
            ?>
        <tr>
            <td><?php echo $item['quantity'];?></td>
            <td><?php echo $item['description'];?></td>
            <td><?php echo $item['rate'];?></td>
            <td><?php echo $item['amount'];?></td>
        </tr>
            <?php
        }
        ?>
        <tr>
            <td colspan="2">&nbsp;</td>
            <td><strong>Total</strong></td>
            <td><strong><?php echo $json_data['Sale']['currency'].' '.$json_data['Total']; ?></strong></td>
        </tr>
        </tbody>
    </table>
</div>